Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

311
Visualizações
React to "click event" in Python (Django)

everyone, beforehand - I'm a bloody but motivated developer beginner.

I am currently trying to react to simple events (click on a button) in the HTML code in my Django project. Unfortunately without success ...

HTML:

<form>
    {% csrf_token %}
    <button id="CSVDownload" type="button">CSV Download!</button>
</form>

JavaScript:

    <script>
        document.addEventListener("DOMContentLoaded", () => {
            const CSVDownload = document.querySelector("#CSVDownload")
            CSVDownload.addEventListener("click", () => {
                console.dir("Test")
            })
        })
    </script>

Do I need JavaScript for this? Or is there a way to react directly to such events in python (Django)?

I am really grateful for all the support.

Since I'm not really "good" yet - a simple solution would be great :)

Python (Django)

    if request.method == "POST":
        projectName = request.POST["projectName"]
        rootDomain = request.POST["rootDomain"]
        startURL = request.POST["startURL"]
....

With this, for example, I managed to react to a kind of event, i.e. when the user sends the form. The problem here, however, is - if I have several forms on one page, then I cannot distinguish which function should be carried out: / I am at a loss

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

This World help you HTML

<form>
    {% csrf_token %}
    <button id="CSVDownload" type="button" onclick="download_csv()">CSV Download!</button>
</form>

Javascript

<script>
       function download_csv{
        document.addEventListener("DOMContentLoaded", () => {
        const CSVDownload = document.querySelector("#CSVDownload")
        CSVDownload.addEventListener("click", () => {
            console.dir("Test")
        })
    })

 }
    
</script>

It might be error while writing the function but this is the way how you react by javascript to the click using on click method

about 4 years ago · Juan Pablo Isaza Relatório

0

Do I need JavaScript for this? Or is there a way to react directly to such events in python (Django)?

I would say that for now JavaScript is the best avenue for you to explore, as whilst there are various ways of getting python to run on the client side (i.e. in your browser), I wouldn't necessarily recommend them to a beginner. Or rather, interpolating them into a Django project might be challenging.

Skulpt

Brython

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda